package com.kafka;

import com.kafka.logs.SystemLogger;
import com.kafka.model.TcpServer;
import com.kafka.model.TcpServerConfig;
import com.kafka.utils.SpringContextUtil;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.stereotype.Component;

/**
 * @ClassName KafaApplication
 * @Description TODD
 * @Author Jesson
 * @Date 2019/1/14 15:25
 * @Version 1.0
 **/
@Component
@SpringBootApplication
public class KafaApplication {
    public static void main(String[] args) {
        try {
            SpringApplication.run(KafaApplication.class, args);
            TcpServerConfig tcpServerConfig = (TcpServerConfig) SpringContextUtil.getBean("tcpServerConfig");
            TcpServer tcpServer = new TcpServer(tcpServerConfig);
            tcpServer.start();
            System.out.println("---------Tcp service started successfully----------");
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println("network service failed to start,exception = " + e);
            SystemLogger.error("network service failed to start {}", e);
            System.exit(0);
        }
    }
}
